
clear 
g sect=1 
drop if sect==1
save $output, replace 


forvalues x = 1(1)$max{
use naics_id_conc_database, clear 
keep if year==$year 
drop sect 
drop if naics=="488991"
sort naics 
egen sect=group(naics) 
keep if sect==`x' 
sort id_conc t 
merge m:1 id_conc t using $base_demo
tab t, gen(time)
keep $condition 
replace $dep=0 if $dep==. 
g _= $dep!=0 
egen nb_block_active=sum(_) 


nbreg $dep $explanatory $condition, nolog ro 
		foreach i in $explanatory {
		g coef_`i'=_b[`i'] 
		g se_`i'=_se[`i'] 
		}
	
keep if $dep>0 // to keep lines with info on the naics sect
duplicates drop naics, force // one elasticity per naics 
keep sect naics coef_* se_*  nb_block_active	
append using $output 
save $output, replace 	
}





